﻿App.Cost = function() {
    return {
        getForm: function() {
            var form = new Ext.form.FormPanel({
                labelAlign: 'left',
                buttonAlign: 'center',
                bodyStyle: 'padding:5px',
                frame: true,
                waitMsgTarget: true,
                reader : new Ext.data.JsonReader({//配置加载查询按钮的结果集
                    root: "rows",            //   该属性是指定包含所有行对象的数组the property which contains an Array of row objects
                	fields: [
                             {name: 'today',mapping:'today'},
                             {name:'pay_type_x',mapping:'pay_type_x'},
                             {name:'pay_type_t',mapping:'pay_type_t'},
                             {name:'pay_type_q',mapping:'pay_type_q'},
                             {name:'sh_traff_fee',mapping:'sh_traff_fee'},
                             {name:'sh_inst_fee',mapping:'sh_inst_fee'},
                             {name:'sh_saf_fee',mapping:'sh_saf_fee'},
                             {name:'sh_pre_fee',mapping:'sh_pre_fee'},
                             {name:'own_fee',mapping:'own_fee'},
                             {name:'re_traff_fee',mapping:'re_traff_fee'},
                             {name:'re_inst_fee',mapping:'re_inst_fee'},
                             {name:'re_saf_fee',mapping:'re_saf_fee'},
                             {name:'in_num',mapping:'in_num'},
                             {name:'in_all',mapping:'in_all'},
                             {name:'truck_send',mapping:'truck_send'},
                             {name:'trunk_receive',mapping:'trunk_receive'},
                             {name:'obj_send',mapping:'obj_send'},
                             {name:'obj_cle',mapping:'obj_cle'},
                             {name:'obj_rec',mapping:'obj_rec'}
                             
                         ]
                }),
                items: [{
                	xtype: 'fieldset',
                	title: '财务类(元)',
                	collapsible: true,
                	items: [{
                        layout:'column',
		                items: [
		                        {
			                    	layout: 'form',
			                    	width:300,
			                    	items:[
						                {
						                    name: 'pay_type_x',
						                    style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                    xtype:"displayfield",
						                    fieldLabel: '现付数'
						                },{
						                    name: 'pay_type_t',
						                    style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                    xtype:"displayfield",
						                    fieldLabel: '提付数'
						                },{
						                    name: 'pay_type_q',
						                    style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                    xtype:"displayfield",
						                    fieldLabel: '签单回付数'
						                }

						           ]
		                        },{
		                        layout: 'form',
		                        width:300,
		                    	items:[
						                {
						                	name: 'sh_traff_fee',
						                	style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                	 xtype:"displayfield",
						                    fieldLabel: '当天入库应收运费'
						                },
						                {
						                	name:'sh_inst_fee',
						                	style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                	 xtype:"displayfield",
						                    fieldLabel: '应收代收'
						                },
						                {
						                    name: 'sh_saf_fee',
						                    style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                    xtype:"displayfield",
						                    fieldLabel: '应收保险费'
						                }
						             ]
				                },{
				                	layout: 'form',
				                	width:300,
			                    	items:[
					                {
					                    name: 're_traff_fee',
					                    style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
					                    xtype:"displayfield",
					                    fieldLabel: '实收运费'
					                },
					                {
					                	name: 're_inst_fee',
					                	style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
					                	 xtype:"displayfield",
					                    fieldLabel: '实收代收'
					                }, {
					                	name: 're_saf_fee',
					                	style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
					                	 xtype:"displayfield",
					                    fieldLabel: '实收保险费'
					                },{
					                	name: 'obj_cle',
					                	style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
					                	 xtype:"displayfield",
					                    fieldLabel: '已交付未结清'
					                }
					              ]
				                }
		                ]
                	}]
                },{
                	xtype: 'fieldset',
                	title: '物流类(件)',
                	collapsible: true,
                	items: [{
                        layout:'column',
		                items: [
		                        {
			                    	layout: 'form',
			                    	width:300,
			                    	items:[
						                {
						                	 name: 'in_num',
						                	 style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                	 xtype:"displayfield",
						                     fieldLabel: '当天入库数'
						                },
						                {
						                    name: 'in_all',
						                    style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                    xtype:"displayfield",
						                    fieldLabel: '库存总数'
						                },{
						                    name: 'truck_send',
						                    style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                    xtype:"displayfield",
						                    fieldLabel: '当天发车数'
						                },{
						                    name: 'trunk_receive',
						                    style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                    xtype:"displayfield",
						                    fieldLabel: '当天接车数'
						                }

						           ]
		                        },{
		                        layout: 'form',
		                        width:300,
		                    	items:[
						                {
						                	name: 'obj_send',
						                	style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                	 xtype:"displayfield",
						                    fieldLabel: '当天发货总数'
						                },
						                {
						                	name: 'obj_rec',
						                	style :"color:red; font:normal 15px tahoma, arial, helvetica, sans-serif;",
						                	 xtype:"displayfield",
						                    fieldLabel: '当天交付总数'
						                }
						             ]
		                        }]
                	}]
                }],
                buttons: [{
                    text: '查询',
                    scope: this,
                    handler: function() {
                        this.query();
                    }
                }]
            });
            return form;
        },
        query: function() {
        	this.form.getForm().load({url:'cost/items',waitMsg:'Loading'});//数据来源的URL
        },
        createMainView : function (id){
        	 var panel = Ext.getCmp(id);
             panel.body.dom.innerHTML = "";
             panel.add(this.form);
        },
        render: function(id) {
            if (!this.form) {
                this.form = this.getForm();
            };
            this.createMainView(id);

        }
    };
} ();
